package com.simpleim.starter.protoBuilder;

import com.simpleim.im.common.bean.msg.ProtoMsg;
import com.simpleim.starter.client.ClientSession;

public class BaseBuilder {

    private ClientSession session;

    private ProtoMsg.HeadType headType;

    private long seqId;

    public BaseBuilder(ProtoMsg.HeadType headType, ClientSession session) {
        this.headType = headType;
        this.session = session;
    }

    public ProtoMsg.Message buildCommon(long seqId) {
        this.seqId = seqId;
        ProtoMsg.Message.Builder builder = ProtoMsg.Message.newBuilder();
        builder.setType(headType)
                .setSessionId(session.getSessionId())
                .setSequence(seqId);
        return builder.buildPartial();
    }

    public ClientSession getSession() {
        return session;
    }

    public void setSession(ClientSession session) {
        this.session = session;
    }

    public ProtoMsg.HeadType getHeadType() {
        return headType;
    }

    public void setHeadType(ProtoMsg.HeadType headType) {
        this.headType = headType;
    }

    public long getSeqId() {
        return seqId;
    }

    public void setSeqId(long seqId) {
        this.seqId = seqId;
    }
}
